package practice2;


import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class P8665 {

    public static String getFlyTime(String info1,String info2) throws ParseException {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String[] times1 = info1.split(" ");
        long interval1;
        if(times1.length>2){
            Date d1 = sdf.parse("2023-1-15 " + times1[0]);
            Date d2 = sdf.parse("2023-1-16 " + times1[1]);
            interval1=d2.getTime()-d1.getTime();
        }else {
            Date d1 = sdf.parse("2023-1-15 " + times1[0]);
            Date d2 = sdf.parse("2023-1-15 " + times1[1]);
            interval1=d2.getTime()-d1.getTime();
        }
        String[] times2 = info2.split(" ");
        long interval2;
        if(times2.length>2){
            Date d1 = sdf.parse("2023-1-15 " + times2[0]);
            Date d2 = sdf.parse("2023-1-16 " + times2[1]);
            interval2=d2.getTime()-d1.getTime();
        }else {
            Date d1 = sdf.parse("2023-1-15 " + times2[0]);
            Date d2 = sdf.parse("2023-1-15 " + times2[1]);
            interval2=d2.getTime()-d1.getTime();
        }
        long interval = (interval1+interval2)/2 - 1000*60*60*8;        //飞行时间的时间戳
        String dateStr = sdf.format(interval);
        return dateStr;
    }

    public static void main(String[] args) throws ParseException {
        Scanner sc = new Scanner(System.in);
        int n =sc.nextInt();
        String s = sc.nextLine();
        for(int i=0;i<n;i++){
            String info1 = sc.nextLine();
            String info2 = sc.nextLine();
            String dateStr = getFlyTime(info1, info2);
            String[] strings = dateStr.split(" ");
            System.out.println(strings[1]);
        }
    }
}
